import util from '../libs/util';
import Cookies from 'js-cookie';

const headers = () => {
    return {'token': Cookies.get('token')};
};

// 登陆
export const login = params => {
    return util.ajax.post('/admin/login', params).then(res => res.data);
};
// 根据token自动登录
export const loginByToken = token => {
    return util.ajax.post('/admin/loginByToken', null, {headers: {'token': token}}).then(res => res.data);
};

// 用户列表
export const systemUserIndex = params => {
    return util.ajax.get('/admin/systemUser/index', {params: params, headers: headers()}).then(res => res.data);
};
// 用户详情
export const systemUserDetail = params => {
    return util.ajax.get('/admin/systemUser/details', {params: params, headers: headers()}).then(res => res.data);
};
// 用户新增
export const systemUserInsert = params => {
    return util.ajax.post('/admin/systemUser/insert', params, {headers: headers()}).then(res => res.data);
};
// 用户修改
export const systemUserUpdate = params => {
    return util.ajax.post('/admin/systemUser/update', params, {headers: headers()}).then(res => res.data);
};
// 用户修改密码
export const systemUserUpdatePassword = params => {
    return util.ajax.post('/admin/systemUser/updatePassword', params, {headers: headers()}).then(res => res.data);
};
// 用户删除
export const systemUserDelete = params => {
    return util.ajax.post('/admin/systemUser/delete', params, {headers: headers()}).then(res => res.data);
};
// 管理管理员角色列表
export const systemUserRole = params => {
    return util.ajax.post('/admin/systemUser/role', params, {headers: headers()}).then(res => res.data);
};
// 查询用户
export const systemUserSearch = params => {
    return util.ajax.get('/admin/systemUser/search', {params: params, headers: headers()}).then(res => res.data);
};
// 充值
export const recharge = params => {
    return util.ajax.post('/admin/systemUser/recharge', params, {headers: headers()}).then(res => res.data);
};

// ---------------------------------------

// 角色修改
export const roleUpdate = params => {
    return util.ajax.post('/admin/role/update', params, {headers: headers()}).then(res => res.data);
};
// 角色列表
export const roleIndex = params => {
    return util.ajax.get('/admin/role/index', {params: params, headers: headers()}).then(res => res.data);
};
// 角色对应权限
export const roleShow = params => {
    return util.ajax.get('/admin/role/show', {params: params, headers: headers()}).then(res => res.data);
};
// 角色列表无分页
export const roleIndexNoPage = params => {
    return util.ajax.get('/admin/role/indexNoPage', {params: params, headers: headers()}).then(res => res.data);
};
// 角色删除
export const roleDelete = params => {
    return util.ajax.post('/admin/role/delete', params, {headers: headers()}).then(res => res.data);
};
// 角色新增
export const roleCreate = params => {
    return util.ajax.post('/admin/role/create', params, {headers: headers()}).then(res => res.data);
};
// 角色详情
export const roleDetail = params => {
    return util.ajax.get('/admin/role/detail', {params: params, headers: headers()}).then(res => res.data);
};
// 角色修改对应权限
export const roleUpdateAuthority = params => {
    return util.ajax.post('/admin/role/updateAuthority', params, {headers: headers()}).then(res => res.data);
};

// ----------------------------------------------------

// 权限列表
export const authorityIndex = params => {
    return util.ajax.get('/admin/authority/index', {params: params, headers: headers()}).then(res => res.data);
};
// 上级权限菜单列表（无分页）
export const authorityParentAuth = params => {
    return util.ajax.get('/admin/authority/parentAuth', {params: params, headers: headers()}).then(res => res.data);
};
// 权限列表（树形无分页）
export const authorityTree = params => {
    return util.ajax.get('/admin/authority/tree', {params: params, headers: headers()}).then(res => res.data);
};
// 权限详情
export const authorityShow = params => {
    return util.ajax.get('/admin/authority/show', {params: params, headers: headers()}).then(res => res.data);
};
// 权限新增
export const authorityCreate = params => {
    return util.ajax.post('/admin/authority/create', params, {headers: headers()}).then(res => res.data);
};
// 权限修改
export const authorityUpdate = params => {
    return util.ajax.post('/admin/authority/update', params, {headers: headers()}).then(res => res.data);
};
// 权限删除
export const authorityDelete = params => {
    return util.ajax.post('/admin/authority/delete', params, {headers: headers()}).then(res => res.data);
};

// ---------------------------------------------------------------

// 订单统计
export const statementsTotal = params => {
    return util.ajax.get('/admin/statements/total', {params: params, headers: headers()}).then(res => res.data);
};

//财务详情
export const statementsDetails = param => {
    return util.ajax.get('/fianceTotal/detail', {
        params: param,
        headers: headers()
    }).then(res => res.data);
};

// 财务展示列表---------------------------------------------------------

export const statementsIndex = params => {
    return util.ajax.get('/fianceTotal/index', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};

// 展示列表(无分页)
export const statementsList = params => {
    return util.ajax.get('/admin/statements/list', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};

// 添加
export const statementsInsert = params => {
    return util.ajax.post('/fianceTotal/insert', params, {headers: headers()}).then(res => res.data);
};

//批量添加
export const statementsAllInsert = params => {
    return util.ajax.post('/admin/statements/allInsert', params, {headers: headers()}).then(res => res.data);
};

// 删除
export const statementsDelete = params => {
    return util.ajax.post('/fianceTotal/delete', params, {headers: headers()}).then(res => res.data);
};

// 修改
export const statementsUpdate = params => {
    return util.ajax.post('/fianceTotal/update', params, {headers: headers()}).then(res => res.data);
};


// 展示日志
export const logIndex = params => {
    return util.ajax.get('/fianceTotal/index', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};

// --------------------------------------------------------------------------------------------------------------------

// 详情
export const bankDetail = params => {
    return util.ajax.get('/admin/bank/detail', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};
// 展示列表
export const bankIndex = params => {
    return util.ajax.get('/admin/bank/index', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};

// 展示列表(无分页)
export const bankList = params => {
    return util.ajax.get('/admin/bank/list', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};

// 添加
export const bankInsert = params => {
    return util.ajax.post('/admin/bank/insert', params, {headers: headers()}).then(res => res.data);
};

// 删除
export const bankDelete = params => {
    return util.ajax.post('/admin/bank/delete', params, {headers: headers()}).then(res => res.data);
};

// 修改
export const bankUpdate = params => {
    return util.ajax.post('/admin/bank/update', params, {headers: headers()}).then(res => res.data);
};

// --------------------------------------------------------------------------------------------------------------------

// 详情
export const addressListDetail = params => {
    return util.ajax.get('/admin/addressList/detail', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};
// 展示列表
export const addressListIndex = params => {
    return util.ajax.get('/admin/addressList/index', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};

// 展示列表(无分页)
export const addressListList = params => {
    return util.ajax.get('/admin/addressList/list', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};

// 添加
export const addressListInsert = params => {
    return util.ajax.post('/admin/addressList/insert', params, {headers: headers()}).then(res => res.data);
};

// 删除
export const addressListDelete = params => {
    return util.ajax.post('/admin/addressList/delete', params, {headers: headers()}).then(res => res.data);
};

// 修改
export const addressListUpdate = params => {
    return util.ajax.post('/admin/addressList/update', params, {headers: headers()}).then(res => res.data);
};

// --------------------------------------------------------------------------------------------------------------------

// 详情
export const projectDetail = params => {
    return util.ajax.get('/admin/project/detail', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};
// 展示列表
export const projectIndex = params => {
    return util.ajax.get('/admin/project/index', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};

// 展示列表(无分页)
export const projectList = params => {
    return util.ajax.get('/admin/project/list', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};

// 添加
export const projectInsert = params => {
    return util.ajax.post('/admin/project/insert', params, {headers: headers()}).then(res => res.data);
};

// 删除
export const projectDelete = params => {
    return util.ajax.post('/admin/project/delete', params, {headers: headers()}).then(res => res.data);
};

// 修改
export const projectUpdate = params => {
    return util.ajax.post('/admin/project/update', params, {headers: headers()}).then(res => res.data);
};

// --------------------------------------------------------------------------------------------------------------------

// 详情
export const userDetail = params => {
    return util.ajax.get('/admin/user/detail', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};
// 展示列表
export const userIndex = params => {
    return util.ajax.get('/admin/user/index', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};

// 展示列表(无分页)
export const userList = params => {
    return util.ajax.get('/admin/user/list', {
        params: params,
        headers: headers()
    }).then(res => res.data);
};

// 添加
export const userInsert = params => {
    return util.ajax.post('/admin/user/insert', params, {headers: headers()}).then(res => res.data);
};

// 删除
export const userDelete = params => {
    return util.ajax.post('/admin/user/delete', params, {headers: headers()}).then(res => res.data);
};

// 修改
export const userUpdate = params => {
    return util.ajax.post('/admin/user/update', params, {headers: headers()}).then(res => res.data);
};

// 修改公司名称
export const settingUpdate = params => {
    return util.ajax.post('/admin/setting/update', params, {headers: headers()}).then(res => res.data);
};

// 获取验证码
export const getVerfiCode = params => {
  return util.ajax.post('/admin/verifCode/getVerfiCode', params, {headers: headers()}).then(res => res.data);
};

// 验证验证码
export const verfiCode = params => {
  return util.ajax.post('/admin/verifCode/verfiCode', params, {headers: headers()}).then(res => res.data);
};
